package GUI;


import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JButton;

import DELEGATES.EmployedDelegate;
import DELEGATES.ManagerDelagate;
import ENTITIES.tbl_Empleado;
import ENTITIES.tbl_Perfil_usuario;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PanelEmpleado extends JPanel implements ActionListener {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	
	private JTextField textField;
	private JTextField textField_2;
	private JTextField textField_4;
	private JTextField textField_1;
	private JTextField jTextField3;
	private JLabel jLabel3;
	private JTextField jTextField2;
	private JLabel jLabel2;
	private JTextField jTextField1;
	private JLabel jLabel1;
	private JPasswordField passwordField;
	private JPasswordField passwordField_1;

	private List<Long> list;
	public PanelEmpleado() {
		
		final ManagerDelagate managerd= new ManagerDelagate();
		setBackground(new Color(135, 206, 235));
		setLayout(null);
		this.setPreferredSize(new java.awt.Dimension(520, 535));

		JPanel panel = new JPanel();
		panel.setLayout(null);
		panel.setBorder(BorderFactory.createTitledBorder(""));
		panel.setBounds(23, 25, 470, 247);
		add(panel);
		
		JLabel lblNombre = new JLabel();
		lblNombre.setText("Nombre ");
		lblNombre.setFont(new Font("SansSerif", Font.PLAIN, 16));
		lblNombre.setBounds(10, 16, 72, 21);
		panel.add(lblNombre);
		
		textField = new JTextField();
		textField.setFont(new Font("SansSerif", Font.PLAIN, 16));
		textField.setBounds(88, 9, 122, 28);
		panel.add(textField);
		
		JLabel lblApellido = new JLabel();
		lblApellido.setText("Apellido ");
		lblApellido.setFont(new Font("SansSerif", Font.PLAIN, 16));
		lblApellido.setBounds(10, 55, 72, 21);
		panel.add(lblApellido);
		
		textField_2 = new JTextField();
		textField_2.setFont(new Font("SansSerif", Font.PLAIN, 16));
		textField_2.setBounds(88, 48, 120, 28);
		panel.add(textField_2);
		
		JLabel label_4 = new JLabel();
		label_4.setText("Direccion");
		label_4.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label_4.setBounds(10, 126, 72, 24);
		panel.add(label_4);
		
		textField_4 = new JTextField();
		textField_4.setFont(new Font("SansSerif", Font.PLAIN, 16));
		textField_4.setBounds(88, 124, 312, 28);
		panel.add(textField_4);
		
		JLabel label_5 = new JLabel();
		label_5.setText("Fecha de contratacion");
		label_5.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label_5.setBounds(10, 171, 159, 22);
		panel.add(label_5);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox.setBounds(175, 169, 55, 27);
		panel.add(comboBox);
		
		JComboBox comboBox_1 = new JComboBox();
		comboBox_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox_1.setBounds(242, 169, 54, 27);
		panel.add(comboBox_1);
		
		JComboBox comboBox_2 = new JComboBox();
		comboBox_2.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox_2.setBounds(308, 169, 92, 27);
		panel.add(comboBox_2);
		
		JLabel label_7 = new JLabel();
		label_7.setText("Perfil");
		label_7.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label_7.setBounds(10, 204, 49, 16);
		panel.add(label_7);
		
		
		//list= managerd.selectAllPerfilUsuarios();
		
		JComboBox comboBox_4 = new JComboBox();
		ComboBoxModel combo_perfilModel = 
				new DefaultComboBoxModel(
						new String[] { "Administrador", "Usuario" });
		comboBox_4.setModel(combo_perfilModel);
		comboBox_4.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox_4.setBounds(97, 199, 133, 26);
		
		panel.add(comboBox_4);
		{
			jLabel1 = new JLabel();
			panel.add(jLabel1);
			jLabel1.setText("Nombre 1 ");
			jLabel1.setFont(new Font("SansSerif",Font.PLAIN,16));
			jLabel1.setBounds(222, 13, 82, 21);
		}
		{
			jTextField1 = new JTextField();
			panel.add(jTextField1);
			jTextField1.setFont(new Font("SansSerif",Font.PLAIN,16));
			jTextField1.setBounds(316, 10, 128, 28);
		}
		{
			jLabel2 = new JLabel();
			panel.add(jLabel2);
			jLabel2.setText("Apellido  1");
			jLabel2.setFont(new Font("SansSerif",Font.PLAIN,16));
			jLabel2.setBounds(224, 52, 78, 21);
		}
		{
			jTextField2 = new JTextField();
			panel.add(jTextField2);
			jTextField2.setFont(new Font("SansSerif",Font.PLAIN,16));
			jTextField2.setBounds(314, 52, 128, 28);
		}
		{
			jLabel3 = new JLabel();
			panel.add(jLabel3);
			jLabel3.setText("Cedula");
			jLabel3.setFont(new Font("SansSerif",Font.PLAIN,16));
			jLabel3.setBounds(10, 96, 72, 24);
		}
		{
			jTextField3 = new JTextField();
			panel.add(jTextField3);
			jTextField3.setFont(new Font("SansSerif",Font.PLAIN,16));
			jTextField3.setBounds(88, 94, 312, 28);
		}

		JPanel panel_1 = new JPanel();
		panel_1.setLayout(null);
		panel_1.setBorder(BorderFactory.createTitledBorder(""));
		panel_1.setBounds(20, 283, 431, 176);
		add(panel_1);
		
		JLabel label = new JLabel();
		label.setText("Usuario");
		label.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label.setBounds(16, 13, 66, 23);
		panel_1.add(label);
		
		textField_1 = new JTextField();
		textField_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		textField_1.setBounds(175, 7, 176, 28);
		panel_1.add(textField_1);
		
		JLabel label_1 = new JLabel();
		label_1.setText("Contrase\u00F1a");
		label_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label_1.setBounds(16, 48, 86, 23);
		panel_1.add(label_1);
		
		passwordField = new JPasswordField();
		passwordField.setText("usuariodelsitema");
		passwordField.setFont(new Font("SansSerif", Font.PLAIN, 16));
		passwordField.setBounds(175, 42, 176, 28);
		panel_1.add(passwordField);
		
		JLabel label_2 = new JLabel();
		label_2.setText("Confirmar Contrase\u00F1a");
		label_2.setFont(new Font("SansSerif", Font.PLAIN, 16));
		label_2.setBounds(15, 73, 154, 32);
		panel_1.add(label_2);
		
		passwordField_1 = new JPasswordField();
		passwordField_1.setText("usuariodelsistema");
		passwordField_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		passwordField_1.setBounds(175, 76, 176, 28);
		panel_1.add(passwordField_1);
		
		JRadioButton radioButton = new JRadioButton();
		radioButton.setText("Crear Usuario");
		radioButton.setFont(new Font("SansSerif", Font.PLAIN, 16));
		radioButton.setBounds(16, 117, 129, 18);
		panel_1.add(radioButton);
		
		JRadioButton radioButton_1 = new JRadioButton();
		radioButton_1.setText("Cambiar Contrase\u00F1a");
		radioButton_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		radioButton_1.setBounds(16, 141, 177, 18);
		panel_1.add(radioButton_1);
		
		JButton button = new JButton();
		button.setText("aceptar");
		button.setFont(new Font("SansSerif", Font.PLAIN, 16));
		button.setBounds(218, 126, 128, 35);
		panel_1.add(button);
		
		JButton button_1 = new JButton();
		button_1.setText("Crear Empleado");
		button_1.setFont(new Font("SansSerif", Font.PLAIN, 16));
		button_1.setBounds(47, 468, 175, 46);
		add(button_1);
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				EmployedDelegate employed = new EmployedDelegate();
				tbl_Perfil_usuario perfil = new tbl_Perfil_usuario();
				
				tbl_Empleado empleado= new tbl_Empleado();
				empleado.setNombre1(textField.getText());
				empleado.setNombre2(jTextField1.getText());
				empleado.setApellido1(textField_2.getText());
				empleado.setApellido2(jTextField2.getText());
				empleado.setCedula(Integer.parseInt(jTextField3.getText()));
				empleado.setCargo("");
				empleado.setDireccion(textField_4.getText());
				perfil.setUsuario(textField_1.getText());
				perfil.setPassword(passwordField.getText());
				empleado.setPerfil(perfil);
				managerd.insertEmpleado(empleado);
				
			}});
			

		JButton button_2 = new JButton();
		button_2.setText("Cancelar");
		button_2.setFont(new Font("SansSerif", Font.PLAIN, 16));
		button_2.setBounds(249, 471, 115, 46);
		add(button_2);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()=="Crear Empleado")
		{
			
		}
	}

}
